package com.wanlian.dao.impl;

import com.wanlian.common.PageCondition;
import com.wanlian.dao.BlackListDao;
import com.wanlian.dao.IntDetailDao;
import com.wanlian.entity.BlackList;
import com.wanlian.entity.IntChangeDetail;
import com.wanlian.model.ResultModel;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class IntDetailDaoImpl extends GenericDaoImpl<IntChangeDetail> implements IntDetailDao {

    public IntDetailDaoImpl() {
        super(IntChangeDetail.class);
    }


    @Override
    public ResultModel queryByUSid(int shid) {
        String hql = String.format("from %s where shid=? ", entityClassName());
        IntChangeDetail intChangeDetail = this.queryForObject(hql, new Object[]{ shid});
        ResultModel resultModel=new ResultModel(true);
        resultModel.setObject(intChangeDetail);
        return resultModel;
    }


    @Override
    public List<IntChangeDetail> queryAllDetail(int status) {
        List<IntChangeDetail> lists = new ArrayList<IntChangeDetail>();
        String hql = String.format("from %s where status = ? ", entityClassName());
        lists = this.queryForList(hql, new Object[]{status});
        return lists;
    }

    @Override
    public IntChangeDetail queryOneDetail() {
        String hql = String.format(" from %s where  status=?  order by picktime desc", entityClassName());
        IntChangeDetail intChangeDetail = this.queryForTopObject(hql, new Object[]{1});
        return intChangeDetail;
    }
}
